1. Field of the Invention
The invention generally relates to a thread-managing mechanism, and more particularly, to a method for managing threads by using an executing time scheduling technique and an electronic device using the same method.
2. Description of Related Art
The applications used on an electronic device currently are developed towards diversification and have a plurality of threads usually requiring simultaneously be operated. When each of independently running threads is to be operated, the operation system (OS) would wake up the processor to execute one or multiple threads to be processed. At the time, the usage durations of the processor may be too dense so as to reduce the time for the processor to enter an idle mode and further consume too much power.
FIGS. 1A-1C are schematic diagrams showing an executing timing of threads and a processor. Referring to FIG. 1, the abscissa herein represents time and the coordinate towards right direction means an increased time, and six time-points A1-A6 on the time axis represent six executing times of the thread A to be executed. It can be seen from FIG. 1A the executing cycle of the thread A is, for example, 100 ms. Referring to FIG. 1B, three time-points B1-B3 on the time axis represents three executing times of the thread B to be executed, while in FIG. 1B, the executing cycle of the thread B is, for example, 200 ms.
The threads A and B are independently running threads. When both the threads A and B need to be executed, the processor would be waked up to execute the threads A and B at appropriate time-points. FIG. 1C is a schematic diagram where the executing timing for the threads A and B is not properly scheduling-managed. It can be seen from FIG. 1C the processor needs to process the thread A or B every 50 ms in shortest situation. Such a too high operation frequency brings a problem of too dense executing periods at the peak duration, and the processor has no sufficient time to enter an idle mode so as to consume higher power. In this regard, how to effectively schedule multiple threads to reduce the power consumption of the processor becomes a project issue to be solved in the field.